import threading
import time


class MyThread(threading.Thread):

    mutex = threading.Lock()

    def __init__(self):
        # super().__init__() #另一种写法
        threading.Thread.__init__(self)
        print("创建MyThread")

    def run(self):
        MyThread.mutex.acquire()
        time.sleep(1)
        print("MyThread over")
        MyThread.mutex.release()